<?php 
session_start();

$email_temp="";

include('config.php');


//Connect to server and select database.
mysql_connect($db_server,$db_user,$db_pass)or die("cannot connect to server");
mysql_select_db($db_database)or die("cannot select DB");


// table name
$tbl_name="user_info";

//get id from the form
$email=$_POST['email'];

if($email!=$email_temp)
{
	
	if (preg_match("/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/", $email)) 
	{
			//check if id exists in database
	$sql="Select * from $tbl_name where email='$email'"; 
	
	// pass the query
	$result=mysql_query($sql); 
	$count=mysql_num_rows($result);
	
		
	 if($count>0) 
				{echo '0';// id already registered
				}
			else
				{
					echo '1'  ;// id available
				}
	
	}
	else
	echo '2'; //invalid id

}
else
{
	echo '1'  ;// id available
	}

?>

